import matplotlib.pyplot as plt
from playLA.Matrix import Matrix
from playLA.Vector import Vector
import math

if __name__ == "__main__":
    points = [[0, 0],
              [0, 5],
              [3, 5],
              [3, 4],
              [1, 4],
              [1, 3],
              [2, 3],
              [2, 2],
              [1, 2],
              [1, 0]]

    x = [point[0] for point in points]
    y = [point[1] for point in points]
    plt.figure(figsize=(5,5))
    plt.xlim(-10, 10)
    plt.ylim(-10, 10)
    plt.plot(x, y)

    # plt.show()

    P = Matrix(points)

    print(P.shape())  # (10, 2)

    # T = Matrix([[2, 0], [0, 1.5]])  # 缩放
    # T = Matrix([[-1, 0], [0, 1]])  # 镜像
    # T = Matrix([[1, 0.5], [0, 1]])  # x错切
    # T = Matrix([[1, 0], [0.5, 1]])  # y错切

    # 数学库中一般用弧度制来表示角度
    theta = math.pi / 3
    # 旋转 60度
    T = Matrix([[math.cos(theta), math.sin(theta)],
                [-math.sin(theta), math.cos(theta)]])

    P2 = T.dot(P.T())

    print(P2)

    plt.plot([P2.col_vector(i)[0] for i in range(P2.col_num())],
             [P2.col_vector(j)[1] for j in range(P2.col_num())])

    plt.show()





